package com.demo.modules.mq.controller;

import com.demo.common.core.result.R;
import com.demo.modules.mq.redis.RedisAnnouncementMessage;
import com.demo.modules.mq.redis.service.RedisMessageProducerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author MyPC
 */
@Api(tags = "RedisMQ接口")
@RequestMapping("/mq-redis")
@RestController
public class RedisMqController {

    @Autowired
    private RedisMessageProducerService redisMessageProducerService;

    @ApiOperation("发送消息")
    @PostMapping("pushMessage")
    public R<Long> pushMessage(String content) {
        RedisAnnouncementMessage redisAnnouncementMessage = new RedisAnnouncementMessage();
        redisAnnouncementMessage.setId("1");
        redisAnnouncementMessage.setContent(content);
        return R.ok(redisMessageProducerService.sendMessage(redisAnnouncementMessage));
    }
}
